package cn.kgc.easybuy.config;

import cn.kgc.easybuy.initalizer.UserCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

	@Autowired
	private UserCheckInterceptor userIntercept;
	
//	@Autowired
//	public MyMvcConfig(UserCheckInterceptor userCheckInterceptor) {
//		this.userCheckInterceptor = userCheckInterceptor;
//	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(userIntercept)
			.addPathPatterns("/**")
				.excludePathPatterns("/login")
			.excludePathPatterns("/addUser")
				.excludePathPatterns("/checkLoginName")
				.excludePathPatterns("/checkEmail")
				.excludePathPatterns("/checkIdentityCode")
				.excludePathPatterns("/checkMobile")
				.excludePathPatterns("/sendEmail")
				.excludePathPatterns("/checkCode")
				.excludePathPatterns("/checkPassword")
				.excludePathPatterns("/selectNewsById")
				.excludePathPatterns("/selectNewsByPage")
				.excludePathPatterns("/selectProductByPage")
				.excludePathPatterns("/selectCategoryById")
				.excludePathPatterns("/selectAllCategory")
				.excludePathPatterns("/selectCategoryByType")
				.excludePathPatterns("/selectRootCategories")
				.excludePathPatterns("/selectCategoryByPage")
				.excludePathPatterns("/selectChildCategory")
				.excludePathPatterns("/selectBuyCarByPage")
				.excludePathPatterns("/selectAllBuyCar")
				.excludePathPatterns("/getCollectList")
				.excludePathPatterns("/ali/return_url")
				.excludePathPatterns("/ali/notify_url")
				.excludePathPatterns("/ali/refundByZfb")
				.excludePathPatterns("/ali/payByWX")
				.excludePathPatterns("/ali/wxNotify");
	}
}
